package opdracht2;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;

public class ScanFile {

	private String fileLocation;

	public ScanFile(String fileLocation) {
		this.fileLocation = fileLocation;

	}

	public int[] parse() {
		FileInputStream fis;

		int[] charArray = new int[256];
		try {
			fis = new FileInputStream(fileLocation);
			Reader in = new InputStreamReader(fis, "UTF-8");
			Reader buffer = new BufferedReader(in);
			int r;
			while ((r = buffer.read()) != -1) {
				charArray[r]++;
			}
			buffer.close();

		} catch (FileNotFoundException e) {
			System.err.println("FileNotFoundException");
		} catch (UnsupportedEncodingException e) {
			System.err.println("UnsupportedEncodingException");
		} catch (IOException e) {
			System.err.println("IOException");
		}

		return charArray;
	}

}
